(function (f) {
    if (typeof exports === 'object' && typeof module !== 'undefined') {
        module.exports = f()
    } else if (typeof defind === 'function' && defind.amd) {
        defind([], f)
    } else {
        var g
        if (typeof window !== 'undefined') {
            g = window
        } else if (typeof global !== 'undefined') {
            g = global
        } else if (typeof self !== 'undefined') {
            g = self
        } else {
            g = this
        }
        g.conferenceUtils = f()
    }
})(function () {
    var define,module,exports
    return (function () {
        function r(e, n, t) {
            function o(i, f) {
                if (!n[i]) {
                    if (!e[i]) {
                        var c = 'function' == typeof require && require
                        if (!f && c) return c(i, !0)
                        if (u) return u(i, !0)
                        var a = new Error('Cannot find module \'' + i + '\'')
                        throw a.code = 'MODULE_NOT_FOUND', a
                    }
                    var p = n[i] = {exports: {}}
                    e[i][0].call(p.exports, function (r) {
                        var n = e[i][1][r]
                        return o(n || r)
                    }, p, p.exports, r, e, n, t)
                }
                return n[i].exports
            }

            for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++) o(t[i])
            return o
        }

        return r
    })()({
        1:[function (require, module, exports) {
            var Socket = require('socket')
            var logger = typeof window === 'undefined' ? console : window.Logger || console

            function VcsSocket(options, callback) {
                if (!(this instanceof VcsSocket)) {
                    return new VcsSocket(options, callback)
                }
                //VcsSocket.super_.call(this)
                options = options || {}
                callback = (callback || noop).bind(this)
                var self = this
                var cws = null
                var appKey = options.appKey
                var limit = options.limit ? options.limit : 16
                var url = options.url

                cws = Socket({
                    url: url,
                    reconnectTimes: null,
                    reconnectTime: 60000,
                    heartMsg: {method: 'ping', key: appKey},
                    handle: options.handle,
                    _init_func: (event) => {
                        callback ? callback(event) : null
                    }
                })
                window.cws = this
                cws.sendMsg = function (message) {
                    message.key = self.appKey
                    if (self.cws) {
                        self.cws.send(message)
                    } else {
                        logger.error('not connected vcs!')
                    }
                }
                Object.defineProperties(this,{
                    'cws':{
                        get:function () {
                            return cws
                        }
                    },
                    'limit':{
                        get:function () {
                            return limit
                        }
                    },
                    'appKey':{
                        get:function () {
                            return appKey
                        }
                    },
                })
            }

            VcsSocket.prototype.joinConference = function (roomName, roomNum, userName, type, address) {
                let message = {
                    method: 'joinRoom',
                    memberType: type,
                    roomName,
                    userName,
                    roomLimit: this.limit,
                    roomNum,
                    mediaAddress: address
                }
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.dispose = function (callback) {
                if (this.cws) {
                    this.cws.close()
                    this.cws = null
                    delete window.cws
                }
                callback ? callback(this.cws) : null
            }
            VcsSocket.prototype.receive = function (name, sdp) {
                let message = {method: 'receiveVideoFrom', sender: name, sdpOffer: sdp}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.leaveRoom = function () {
                let message = {method: 'leaveRoom'}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.closeRoom = function (roomName, roomNum) {
                let message = {method: 'closeRoom', roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.kick = function(roomName, roomNum, userName) {
                let message = {method:'kickRoom',userName,roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.iceCandidate = function (candidate, userName) {
                let message = {method: 'onIceCandidate', candidate, userName}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.startRecord = function (roomName, roomNum) {
                let message = {method: 'startRecord', roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.stopRecord = function (roomName, roomNum) {
                let message = {method: 'stopRecord', roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.mute = function (roomName, roomNum, userName) {
                let message = {method: 'mute', roomName, roomNum, userName}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.unMute = function(roomName, roomNum, userName) {
                let message = {method:'unMute',roomName,roomNum, userName}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.muteVideo = function() {
                let message = {method: 'muteVideo'}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.unMuteVideo = function() {
                let message = {method: 'unMuteVideo'}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.muteAll = function(roomName, roomNum)  {
                let message = {method:'muteAll',roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.unMuteAll = function(roomName, roomNum) {
                let message = {method:'unMuteAll',roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.roomParticipantsNumber = function(roomName, roomNum) {
                let message = {method:'participantNumber',roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.roomParticipants = function(roomName, roomNum) {
                let message = {method:'meetingParticipants',roomName, roomNum}
                this.cws.sendMsg(message)
            }
            VcsSocket.prototype.roomInfos = function () {
                let message = {method: 'roomInfo'}
                this.cws.sendMsg(message)
            }

            module.exports = VcsSocket

            function noop(error) {
                if (error)
                    logger.error(error)
            }

        },{'socket':5,'room':6,'participant':7}],
        2:[function (require, module, exports) {
            if (window.addEventListener) {
                module.exports = require('./index')
            }
        },{'./index':3}],
        3:[function (require, module, exports) {
            var VcsSocket = require('./VcsSocket')
            var Room = require('./Room')
            var Participant = require('./Participant')
            exports.VcsSocket = VcsSocket
            exports.Room = Room
            exports.Participant = Participant
        },{'./VcsSocket':1,'./Room':6,'./Participant':7}],
        5:[function (require, module, exports) {
            var logger = typeof window === 'undefined' ? console : window.Logger || console
            function Socket(options) {
                if (!(this instanceof Socket)) {
                    return new Socket(options)
                }
                //Socket.super_.call(this)
                /*url*/
                var ws = null
                /*状态 链接状态*/
                var _alive = false
                /*类参数*/
                var _params = null
                /*计时器*/
                var _reconnect_timer = null
                /*心跳计时器*/
                var _heart_time = null
                /*信息 onmessage */
                var _message_func = options._message_func

                var _heart_func = options._heart_func

                var _init_func = options._init_func

                var handle = options.handle

                var heartBeat = options.heartBeat ? options.heartBeat : 30000

                /*心跳信息*/
                var heartMsg = options.heartMsg ? options.heartMsg : 'ping'

                var reconnect = options.reconnect == undefined ? true : options.reconnect

                var lockReconnect = false

                var reconnectTime = options.reconnectTime ? options.reconnectTime : 5000

                var reconnectTimes = options.reconnectTimes ? options.reconnectTimes : 10

                var messageCache = []

                _params = options

                var that = this

                function init() {
                    clearInterval(_heart_time)
                    let params = _params
                    let {url,port} = params
                    let ws_url = port ? url + ':'+port : url
                    ws ? delete ws : null
                    ws = new WebSocket(ws_url)
                    if (_message_func) {
                        onmessage()
                    }

                    ws.onopen = () => {
                        open()
                    }
                    if (_message_func) {
                        ws.onmessage = data => {
                            messageCache.push(data)
                        }
                    }

                    ws.onclose = () => {
                        onclose()
                    }

                    ws.onerror = () => {
                        onerror()
                    }

                }

                function onmessage(func, all = false) {
                    if (messageCache.length > 0) {
                        for (let i = 0; i < messageCache.length; i++) {
                            func(!all?messageCache[i].data:messageCache[i])
                        }
                        messageCache = []
                    }
                    ws.onmessage = data => {
                        _message_func = func
                        func(!all ? data.data : data)
                    }
                }

                function open() {
                    if (ws.readyState === 1) {
                        openInit()
                    }else{
                        setTimeout(()=>{
                            open()
                        },1000)
                    }
                }

                function openInit() {
                    _alive = true
                    clearInterval(_reconnect_timer)
                    if (_init_func) {
                        _init_func(that)
                    }
                    onmessage(handle, false)
                    onheartbeat(_heart_func)
                }

                function onheartbeat(func) {
                    if (_alive === true) {
                        _heart_time = setInterval(()=>{
                            send(heartMsg)
                            func ? func(that) : false
                        },heartBeat)
                    }
                }

                function onreconnect(func) {
                    _reconnect_timer = setInterval(() => {
                        if (lockReconnect) {
                            return
                        }
                        if (reconnectTimes) {
                            if (reconnectTimes <= 0) {
                                clearInterval(_reconnect_timer)
                                return
                            } else {
                                reconnectTimes--
                            }
                        }
                        lockReconnect = true
                        init()
                        func ? func(that) : false
                    }, reconnectTime)
                }
                function send(text) {
                    if (_alive === true) {
                        text = typeof text === 'string' ? text : JSON.stringify(text)
                        ws.send(text)
                    }
                }
                function close() {
                    if (_alive === true) {
                        ws.close()
                    }
                }

                function onopen(func) {
                    ws.onopen = event => {
                        if (_reconnect_timer) {
                            clearInterval(_reconnect_timer)
                        }
                        _alive = true
                        func ? func(event) : false
                    }
                }

                function onclose(func) {
                    ws.onclose = event => {
                        _alive = false
                        clearInterval(_heart_time)
                        if (reconnect === true) {
                            onreconnect()
                        }
                        func ? func(event) : false
                    }
                }

                function onerror(func) {
                    ws.onerror = event => {
                        func ? func(event) : false
                    }
                }

                init()

                Object.defineProperties(this,{
                    'send':{
                        get:function () {
                            return send
                        }
                    },
                    'close':{
                        get:function () {
                            return close
                        }
                    }
                })

            }

            Socket.prototype.send = function (text) {
                this.send(text)
            }
            Socket.prototype.close = function () {
                this.close()
            }

            module.exports = Socket
        },{}],
        6:[function (require, module, exports) {
            var logger = typeof window === 'undefined' ? console : window.Logger || console
            var Participant = require('participant')
            function noop(error) {
                if (error)
                    logger.error(error)
            }

            function forEach(arr, fn) {
                if(!arr.length || !fn) return
                let i = -1
                let len = arr.length
                while(++i < len){
                    let item = arr[i]
                    fn(item,i,arr)
                }
            }

            function sort(obj1, obj2) {
                let key = 'order'
                return obj1[key] - obj2[key]
            }

            function getFormatDate(fmt, date) {
                let ret;
                let opt = {
                    "Y+": date.getFullYear().toString(),        // 年
                    "m+": (date.getMonth() + 1).toString(),     // 月
                    "d+": date.getDate().toString(),            // 日
                    "H+": date.getHours().toString(),           // 时
                    "M+": date.getMinutes().toString(),         // 分
                    "S+": date.getSeconds().toString()          // 秒
                    // 有其他格式化字符需求可以继续添加，必须转化成字符串
                }
                for (let k in opt) {
                    ret = new RegExp("(" + k + ")").exec(fmt);
                    if (ret) {
                        fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
                    }
                }
                return fmt;
            }

            function Room(options, callback) {
                if (!(this instanceof Room)) {
                    return new Room(options,callback)
                }
                options = options || {}
                callback = (callback || noop).bind(this)
                //开会中成员(名称)
                var meeting = []
                //固定成员
                var fixed = {}
                //临时成员
                var temp = {}
                //邀请成员(名称)
                var invite = []

                var name = options.name
                var no = options.no
                var number = options.number
                var route = options.route
                var host = options.host
                var intercom = options.intercom
                var isVideo = options.isVideo
                var record = options.record
                var forceRecord = options.forceRecord
                var isTemp = options.isTemp
                var deptId = options.deptId
                var mute = options.mute
                var isMeeting = false

                var meetingInfos = []

                var confApi = options.confApi
                Object.defineProperties(this,{
                    'meeting':{
                        get:function () {
                            return meeting
                        },
                        set: function (v) {
                            meeting = v
                        }
                    },
                    'fixed':{
                        get:function () {
                            return fixed
                        },
                        set:function (v) {
                            fixed = v
                        }
                    },
                    'temp':{
                        get:function () {
                            return temp
                        },
                        set:function (v) {
                            temp = v
                        }
                    },
                    'invite':{
                        get:function () {
                            return invite
                        },
                        set:function (v) {
                            invite = v
                        }
                    },
                    'name':{
                        get:function () {
                            return name
                        },
                        set:function (v) {
                            name = v
                        }
                    },
                    'no':{
                        get:function () {
                            return no
                        },
                        set:function (v) {
                            no = v
                        }
                    },
                    'number':{
                        get:function () {
                            return number
                        },
                        set:function (v) {
                            number = v
                        }
                    },
                    'route':{
                        get:function () {
                            return route
                        },
                        set:function (v) {
                            route = v
                        }
                    },
                    'host':{
                        get:function () {
                            return host
                        },
                        set:function (v) {
                            host = v
                        }
                    },
                    'intercom':{
                        get:function () {
                            return intercom
                        },
                        set:function (v) {
                            intercom = v
                        }
                    },
                    'isVideo':{
                        get:function () {
                            return isVideo
                        },
                        set:function (v) {
                            isVideo = v
                        }
                    },
                    'record':{
                        get:function () {
                            return record
                        },
                        set:function (v) {
                            record = v
                        }
                    },
                    'forceRecord':{
                        get:function () {
                            return forceRecord
                        },
                        set:function (v) {
                            forceRecord = v
                        }
                    },
                    'isTemp':{
                        get:function () {
                            return isTemp
                        },
                        set:function (v) {
                            isTemp = v
                        }
                    },
                    'deptId':{
                        get:function () {
                            return deptId
                        },
                        set:function (v) {
                            deptId = v
                        }
                    },
                    'mute':{
                        get:function () {
                            return mute
                        },
                        set:function (v) {
                            mute = v
                        }
                    },
                    'isMeeting':{
                        get: function () {
                            return isMeeting
                        },
                        set: function (v) {
                            isMeeting = v
                        }
                    },
                    'meetingInfos':{
                        get: function () {
                            return meetingInfos
                        },
                        set: function (v) {
                            meetingInfos = v
                        }
                    },
                    'confApi':{
                        get: function () {
                            return confApi
                        }
                    }
                })

            }

            Room.prototype.asyncInfo = function(name, type) {
                let json = {time: getFormatDate('HH:MM:SS', new Date()), name, room: this.name, type}
                this.meetingInfos.unshift(json)
            }
            Room.prototype.info = function(key, value, appKey, type) {
                if (!key) {
                    key = 'name'
                }
                let pt = null
                let isTemp = false
                for (const _key in this.temp) {
                    let participant = this.temp[_key]
                    if (participant[key] === value) {
                        isTemp = participant.isTemp
                        if (appKey) {
                            if (participant.gradeNumber === appKey) {
                                pt = participant
                                break
                            }
                        } else {
                            pt = participant
                            break
                        }
                    }
                }
                if (!isTemp) {
                    for (const _key in this.fixed) {
                        let participant = this.fixed[_key]
                        if (participant[key] === value) {
                            isTemp = participant.isTemp
                            if (appKey) {
                                if (participant.gradeNumber === appKey) {
                                    pt = participant
                                    break
                                }
                            } else {
                                pt = participant
                                break
                            }
                        }
                    }
                }

                let json = {}
                if (!pt) {
                    json.name = value
                } else {
                    json.name = pt.name
                }
                json.time = getFormatDate('HH:MM:SS', new Date())
                json.room = this.name
                json.type = type

                this.meetingInfos.unshift(json)

            }
            Room.prototype._inRoom = function (number, appKey) {
                return new Promise((resolve, reject) => {
                    let result = {
                        room:this,
                        data:null
                    }
                    for (const key in this.fixed) {
                        let participant = this.fixed[key]
                        if (participant.number == number) {
                            if (appKey) {
                                if (appKey == participant.gradeNumber) {
                                    result.data = participant
                                    resolve(result)
                                    return
                                }
                            } else {
                                result.data = participant
                                resolve(result)
                                return
                            }
                        }
                    }
                    for (const key in this.temp) {
                        let participant = this.temp[key]
                        if (participant.number == number) {
                            if (appKey) {
                                if (appKey == participant.gradeNumber) {
                                    result.data = participant
                                    resolve(result)
                                    return
                                }
                            } else {
                                result.data = participant
                                resolve(result)
                                return
                            }
                        }
                    }
                    result.data = null
                    resolve(result)
                })
            }
            Room.prototype.addParticipant = function(participant, inRoom) {
                return new Promise((resolve, reject) => {
                    let key = participant.name
                    if (participant.type == 1 && participant.number) {
                        key = participant.number
                    }
                    if (participant.isTemp) {
                        let _participant = this.temp[key]
                        if (_participant) {
                            participant.rtcPeer = _participant.rtcPeer
                            participant.speakHark = _participant.speakHark
                            participant.muted = _participant.muted
                        }
                        if (participant.rtcPeer) {
                            participant.muteVideo = _participant.muteVideo
                        }
                        this.temp[key] = participant
                    } else {
                        let _participant = this.fixed[key]
                        if (_participant) {
                            participant.rtcPeer = _participant.rtcPeer
                            participant.speakHark = _participant.speakHark
                            if (this.isVideo && _participant.type != 1 && _participant.status === 'Talking') {
                                participant.setStatus(_participant.status)
                            }
                            participant.muted = _participant.muted
                        }

                        let __participant = this.temp[key]
                        if (__participant) {
                            delete this.temp[key]
                        }
                        if (participant.rtcPeer) {
                            participant.muteVideo = _participant.muteVideo
                        }

                        this.fixed[key] = participant
                    }
                    if (inRoom && (participant.status === 'Talking' || participant.status === 'Ringing')) {
                        this.isMeeting = true
                        if (participant.status === 'Talking') {
                            if (this.meeting.indexOf(participant.name) < 0) {
                                this.meeting.push(participant.name)
                            }
                            this.removeInviteParticipant('name', participant.name)
                        }
                        let result = {
                            room:this,
                            data:participant
                        }
                        resolve(result)
                    }
                })
            }
            Room.prototype.removeParticipant = function(key, value, appKey) {
                return new Promise((resolve, reject) => {
                    if (!key) {
                        key = 'name'
                    }
                    let participant = null
                    for (const pk in this.temp) {
                        let _participant = this.temp[pk]
                        if (_participant[key] === value) {
                            if (appKey) {
                                if (_participant.gradeNumber === appKey) {
                                    participant = _participant
                                    break
                                }
                            } else {
                                participant = _participant
                                break
                            }
                        }
                    }
                    if (!participant) {
                        for (const pk in this.fixed) {
                            let _participant = this.fixed[pk]
                            if (_participant[key] === value) {
                                if (appKey) {
                                    if (_participant.gradeNumber === appKey) {
                                        participant = _participant
                                        break
                                    }
                                } else {
                                    participant = _participant
                                    break
                                }
                            }
                        }
                    }
                    if (!participant) {
                        reject('no match participant!')
                        return console.error('no match participant!')
                    }
                    if (participant.isTemp) {
                        delete this.temp[participant.name]
                    } else {
                        let json = {
                            name: participant.name,
                            type: participant.type,
                            canInvite: true,
                            number: participant.number
                        }
                        this.invite.unshift(json)
                    }
                    if (this.meeting.indexOf(participant.name) > -1) {
                        this.meeting.splice(this.meeting.indexOf(participant.name), 1)
                        let result = {
                            room:this,
                            data:participant
                        }
                        resolve(result)
                    }
                    if (this.meeting.length <= 0) {
                        this.dispose()
                    }
                })
            }
            Room.prototype.changeVcsParticipant = function(data) {
                return new Promise((resolve, reject) => {
                    if (!data) {
                        reject('data error')
                        return console.error('data error!')
                    }
                    let participant = this.fixed[data.name]
                    if (!participant) {
                        participant = this.temp[data.name]
                    }
                    if (participant) {
                        participant.muted = data.mute
                        if (data.muteVideo != undefined) {
                            participant.muteVideo = data.muteVideo
                        }
                        participant.setStatus('Talking')
                        this.isMeeting = true
                        if (participant.type == 4 || participant.type == 5) {
                            participant.muted = true
                            data.mute = true
                        }
                        if (participant.muted) {
                            participant.meetingIcon = 'conf_mute'
                        } else {
                            participant.meetingIcon = 'conf'
                        }
                        if (this.meeting.indexOf(participant.name) < 0) {
                            this.meeting.push(participant.name)
                        }
                        let result = {
                            room:this,
                            data:[participant]
                        }
                        resolve(result)
                        this.removeInviteParticipant('name', participant.name)
                    } else {
                        let _participants = []
                        let type = data.type
                        if (type == 'SIP话机') {
                            type = 'sip'
                        } else if (type == '摄像头') {
                            type = 'camera'
                            data.mute = true
                        }
                        let _participant = {name: data.name, type: type, mute: data.mute, muteVideo: data.muteVideo}
                        _participants.push(_participant)
                        this.confApi.queryVcsConferenceMembers(_participants).then(result => {
                            if (result.code === 200) {
                                let _data = result.data
                                let _arr = []
                                forEach(_data, d => {
                                    let name = d.name
                                    if (d.channel) {
                                        name = d.name + '_' + d.channel
                                        this.removeInviteParticipant('name', d.name)
                                    }
                                    let __options = {
                                        name: name,
                                        roomName: this.name,
                                        number: d.exten,
                                        type: type == 'camera' ? 4 : d.type,
                                        icon: type == 'camera' ? 'glyphicon glyphicon-facetime-video':'',
                                        isVcs: d.vcs,
                                        isTemp: d.temp,
                                        gradeNumber: d.gradeNum,
                                        gradeName: d.gradeName,
                                        net: d.net,
                                        deptId: d.deptId,
                                        deptName: d.deptName,
                                        isControl:d.name == username,
                                    }
                                    let __participant = Participant(__options)
                                    if (d.channel) {
                                        __participant.realName = d.name
                                    }
                                    __participant.isTemp = d.temp
                                    if (data.muteVideo != undefined) {
                                        __participant.muteVideo = data.muteVideo
                                    }
                                    if (d.inRoom) {
                                        if (d.mute) {
                                            __participant.muted = true
                                            __participant.meetingIcon = 'conf_mute'
                                        } else {
                                            __participant.muted = false
                                            __participant.meetingIcon = 'conf'
                                        }
                                    } else {
                                        __participant.meetingIcon = ''
                                    }
                                    if (d.status === 'UnKnown') {
                                        d.status = 'UnKnow'
                                    }
                                    __participant.setStatus(d.status)
                                    __participant.setDept(d.deptId, d.deptName)
                                    __participant.icon = type == 'camera' ? 'glyphicon glyphicon-facetime-video':''
                                    __participant.net = d.net
                                    __participant.gradeName = d.gradeName

                                    this.addParticipant(__participant, d.inRoom)
                                    _arr.push(__participant)
                                })
                                //无需添加
                                /*if (this.meeting.indexOf(data.name) < 0) {
                                    this.meeting.push(data.name)
                                }*/

                                let _result = {
                                    room: this,
                                    data:_arr
                                }
                                resolve(_result)
                                this.removeInviteParticipant('name', data.name)
                            }
                        })
                    }
                })
            }
            Room.prototype.vcsLeave = function(json) {
                return new Promise((resolve, reject) => {
                    let isTemp = false
                    let participant = this.fixed[json.name]
                    if (!participant) {
                        participant = this.temp[json.name]
                        if (participant) {
                            isTemp = true
                            delete this.temp[json.name]
                        }
                    }
                    if (participant) {
                        participant.dispose()
                        if (participant.status === 'Talking') {
                            participant.setStatus('Idle')
                        }
                        if (participant.type == 4 && participant.isRtsp) {
                            participant.setStatus('UnKnow')
                        }
                        participant.meetingIcon = ''
                    }
                    if (this.meeting.indexOf(json.name) > -1) {
                        this.meeting.splice(this.meeting.indexOf(json.name), 1)
                    }
                    let result = {
                        room:this,
                        data:participant
                    }
                    resolve(result)

                    if (participant.isControl) {
                        if (this.meeting.length > 0) {
                            for (const key in this.fixed) {
                                this.fixed[key].dispose()
                            }
                            for (const key in this.temp) {
                                this.temp[key].dispose()
                            }
                        }

                    }
                    if (isTemp) {
                        return
                    }

                    let info = {
                        name: participant.name,
                        type: participant.type,
                        canInvite: true,
                        number: participant.number
                    }
                    this.invite.unshift(info)
                    if (this.isTemp) {
                        if (Object.keys(this.temp).length <= 0) {
                            //todo close room
                            this.dispose()
                        }
                    }
                })
            }
            Room.prototype.vcsCandidate = function(json, number) {
                let participant = this.fixed[json.name]
                if (!participant) {
                    participant = this.temp[json.name]
                }
                if (!participant.rtcPeer) {
                    if (number == 1) {
                        return
                    }
                    setTimeout(() => {
                        this.vcsCandidate(json, 1)
                    }, 500)
                }
                if (!participant.rtcPeer) {
                    return console.error('participant :%s no rtcpeer!', participant.name)
                }
                participant.rtcPeer.addIceCandidate(json.candidate, function (error) {
                    if (error) return console.error('Error adding candidate:', error)
                })
            }
            Room.prototype.vcsAnswer = function(json) {
                let participant = this.fixed[json.name]
                if (!participant) {
                    participant = this.temp[json.name]
                }
                if (!participant.rtcPeer) {
                    return console.error('participant : %s answer error!', participant.name)
                }
                participant.rtcPeer.processAnswer(json.sdpAnswer, function (error) {
                    if (error) return console.error('Participant answer error:', error)
                })
            }
            Room.prototype.addVcsParticipant = function(data) {
                return new Promise((resolve, reject) => {
                    if (!data || data.length <= 0) {
                        reject('no data!')
                        return
                    }
                    let add = []
                    if (data.roomName === this.name) {
                        if (!this.forceRecord) {
                            this.record=data.record
                        }
                        let participants = data.participantNames
                        if (participants && participants.length > 0) {
                            for (let i = 0; i < participants.length; i++) {
                                let name = participants[i].name
                                if (this.meeting.indexOf(name) < 0) {
                                    this.meeting.push(name)
                                    this.changeVcsParticipant(participants[i])
                                    add.push(name)
                                }
                            }
                        }
                    }
                    let result = {
                        room:this,
                        data:add
                    }
                    resolve(result)
                })
            }
            Room.prototype.changeInvite = function(key, appKey, value) {
                return new Promise((resolve, reject) => {
                    if (!this.isMeeting) {
                        reject('meeting not start!')
                        return console.info('会议未开始!')
                    }
                    if (!key) {
                        key = 'name'
                    }
                    let reInvite = null
                    for (let i = 0; i < this.invite.length; i++) {
                        let participant = this.invite[i]
                        if (participant[key] === value) {
                            if (appKey) {
                                if (appKey === participant.gradeNumber) {
                                    reInvite = participant
                                    break
                                }
                            } else {
                                reInvite = participant
                                break
                            }
                        }
                    }
                    if (reInvite) {
                        reInvite = true
                    }
                    let result = {
                        room:this,
                        data:reInvite
                    }
                    resolve(result)
                })
            }
            Room.prototype.clearParticipant = function() {
                if (this.isVideo) {
                    if (!this.isMeeting) {
                        this.fixed={}
                        this.temp={}
                        this.meeting=[]
                    }
                }else {
                    this.fixed={}
                    this.temp={}
                    this.meeting=[]
                    this.isMeeting=false
                }
            }
            Room.prototype.getParticipants = function() {
                let participants = []
                let gbNames = new Set()
                for (const key in this.temp) {
                    let _participant = this.temp[key]
                    if (_participant.realName !== _participant.name) {
                        gbNames.add(_participant.realName)
                    }
                    participants.push(this.temp[key])
                }
                let _gbNames = Array.from(gbNames)
                for (const key in this.fixed) {
                    let _participant = this.fixed[key]
                    if (_gbNames.length > 0) {
                        if ((_participant.type == 4 || _participant.type == 5) && _gbNames.indexOf(_participant.name) > -1) {
                            continue
                        }
                    }
                    participants.unshift(this.fixed[key])
                }
                participants.sort(sort)
                return participants
            }
            Room.prototype.getParticipant = function(name, type) {
                let participant1 = this.fixed[name]
                let participant2 = this.temp[name]
                if (type == 'temp') {
                    return participant2
                }else if (type == 'fix') {
                    return participant1
                } else {
                    return participant1 ? participant1 : participant2
                }
            }
            Room.prototype.getParticipantByNumber = function(number, appKey) {
                if (!number) {
                    return null
                }
                for (const key in this.fixed) {
                    let _participant = this.fixed[key]
                    if (appKey) {
                        if (appKey === _participant.gradeNumber && _participant.number === number) {
                            return _participant
                        }
                    }else {
                        if (_participant.number === number) {
                            return _participant
                        }
                    }
                }
                for (const key in this.temp) {
                    let _participant = this.temp[key]
                    if (appKey) {
                        if (appKey === _participant.gradeNumber && _participant.number === number) {
                            return _participant
                        }
                    }else {
                        if (_participant.number === number) {
                            return _participant
                        }
                    }
                }
                return null
            }
            Room.prototype.reloadRoom = function(number, appKey) {
                return new Promise((resolve, reject) => {
                    let result = {
                        room:this,
                        data:null
                    }
                    if (this.isTemp) {
                        this.confApi.queryTempConferenceMembers(this.name).then(response=>{
                            if (response.code === 10002) {
                                reject(response)
                            }
                            if (response.code === 200) {
                                let data = response.data
                                if (data && data.length > 0) {
                                    data.forEach(d=>{
                                        let options = {
                                            name: d.name,
                                            roomName: this.name,
                                            number: d.exten,
                                            type: d.type,
                                            isVcs: d.vcs,
                                            isTemp: d.temp,
                                            gradeNumber: d.gradeNum,
                                            gradeName: d.gradeName,
                                            net: d.net,
                                            deptId: d.deptId,
                                            deptName: d.deptName,
                                            icon: processIcon(d.type, d.iconType),
                                            isControl:d.name == username,
                                        }
                                        let participant = Participant(options)
                                        d.status == 'UnKnown' ? d.status = 'UnKnow' : null

                                        participant.setStatus(d.status)
                                        this.addParticipant(participant,d.inRoom)
                                    })
                                }else{
                                    reject(response)
                                }
                            }else{
                                reject(response)
                            }
                        })
                    }else{
                        this.confApi.queryConferenceMembers(this.no,this.name).then(response=>{
                            if (response.code === 200) {
                                let data = response.data
                                if (data && data.length > 0) {
                                    data.forEach(d=>{
                                        let options = {
                                            name: d.name,
                                            roomName: this.name,
                                            number: d.exten,
                                            type: d.type,
                                            isVcs: d.vcs,
                                            isTemp: d.temp,
                                            gradeNumber: d.gradeNum,
                                            gradeName: d.gradeName,
                                            net: d.net,
                                            deptId: d.deptId,
                                            deptName: d.deptName,
                                            mute: d.mute,
                                            icon: processIcon(d.type, d.iconType),
                                            isControl:d.name == username,
                                        }
                                        let participant = Participant(options)
                                        participant.setMute(d.mute)
                                        d.status == 'UnKnown' ? d.status = 'UnKnow' : null

                                        participant.setStatus(d.status)
                                        this.addParticipant(participant,d.inRoom)
                                    })
                                }
                            }else{
                                reject(response)
                            }
                        })
                    }
                    result.data = this.getParticipants()
                    resolve(result)
                })
            }
            Room.prototype.clearInvite = function() {
                if (!this.isMeeting) {
                    this.invite=[]
                }
            }
            Room.prototype.addInviteParticipant = function(data) {
                if (this.invite.length <= 0) {
                    this.invite.push(data)
                    return
                }
                let exists = this.invite.filter(p => p.name === data.name)
                if (exists && exists.length > 0 || this.meeting.indexOf(data.name) > 0) {
                    return
                }
                this.invite.push(data)
            }
            Room.prototype.removeInviteParticipant = function(key, value, appKey) {
                if (this.invite.length <= 0) {
                    return
                }
                if (!key) {
                    key = 'name'
                }
                let index = -1
                let toInvite = null
                for (let i = 0; i < this.invite.length; i++) {
                    let ring = this.invite[i]
                    if (ring[key] === value) {
                        if (appKey) {
                            if (ring.gradeNumber === appKey) {
                                index = i
                                toInvite = ring
                            }
                        }else {
                            index = i
                            toInvite = ring
                        }
                    }
                }
                if (index > -1) {
                    this.invite.splice(index, 1)
                }
                return toInvite
            }
            Room.prototype.meetings = function(status) {
                if (!status) {
                    status = 'Talking'
                }
                let _participants = []
                if (this.meeting.length <= 0) {
                    return _participants
                }
                for (let i = 0; i < this.meeting.length; i++) {
                    let participant = null
                    let pm = this.meeting[i]
                    for (const key in this.fixed) {
                        let fixedParticipant = this.fixed[key]
                        if (fixedParticipant.name === pm) {
                            participant = fixedParticipant
                            break
                        }
                    }
                    if (!participant) {
                        for (const key in this.temp) {
                            let tempParticipant = this.temp[key]
                            if (tempParticipant.name === pm) {
                                participant = tempParticipant
                                break
                            }
                        }
                    }
                    if (participant) {
                        if (status) {
                            if (participant.status === status) {
                                _participants.push(participant)
                            }
                        }else {
                            _participants.push(participant)
                        }
                    }
                }
                return _participants
            }
            Room.prototype.muteAll = function() {
                if (this.isVideo) {
                    for (const key in this.fixed) {
                        this.fixed[key].setMute(true)
                        this.asyncInfo(this.fixed[key].name, 'mute')
                    }
                    for (const key in this.temp) {
                        this.temp[key].setMute(true)
                        this.asyncInfo(this.temp[key].name, 'mute')
                    }
                }
                this.mute=true
            }
            Room.prototype.unMuteAll = function() {
                if (this.isVideo) {
                    for (const key in this.fixed) {
                        this.fixed[key].setMute(false)
                        this.asyncInfo(this.fixed[key].name, 'unMute')
                    }
                    for (const key in this.temp) {
                        this.temp[key].setMute(false)
                        this.asyncInfo(this.temp[key].name, 'unMute')
                    }
                }
                this.mute=false
            }
            Room.prototype.inRoom = function(name) {
                return this.meeting.indexOf(name) > -1
            }
            Room.prototype.dispose = function() {
                return new Promise((resolve, reject) => {
                    let result = {
                        room:this,
                        data:null
                    }
                    if (this.isVideo) {
                        for (const key in this.temp) {
                            let participant = this.temp[key]
                            participant.dispose()
                        }
                        for (const key in this.fixed) {
                            let participant = this.fixed[key]
                            participant.dispose()
                        }
                    }

                    this.isMeeting=false
                    this.record=this.forceRecord
                    this.meeting=[]
                    this.invite=[]
                    this.temp={}

                    resolve(result)
                })
            }

            module.exports = Room
        },{'participant':7}],
        7:[function (require, module, exports) {
            var logger = typeof window === 'undefined' ? console : window.Logger || console

            function Participant(options) {
                if (!(this instanceof Participant)) {
                    return new Participant(options)
                }
                //Participant.super_.call(this)
                options = options || {}
                var name = options.name
                var videoId = `video-${options.name}`
                var audioId = `audio-${options.name}`
                var muted = options.mute || false
                var speaking = false
                var muteVideo = false
                var deptName = options.deptName
                var deptId = options.deptId
                var roomName = options.roomName
                var isVcs = options.isVcs
                var isTemp = options.isTemp
                var isGrade = !!options.gradeNumber
                var number = options.number
                var type = options.type
                var status = ''
                var gradeNumber = options.gradeNumber
                var gradeName = options.gradeName
                var net = null
                var icon = options.icon
                var meetingIcon = null
                var order = 1
                var isRtsp = false
                var realName = null
                var isControl = options.isControl
                if (type == 1) {
                    muteVideo = true
                }
                Object.defineProperties(this,{
                    'rtcPeer':{writable:true},
                    'speakHark':{writable:true},
                    'name':{
                        get:function () {
                            return name
                        }
                    },
                    'videoId':{
                        get:function () {
                            return videoId
                        }
                    },
                    'audioId':{
                        get:function () {
                            return audioId
                        }
                    },
                    'muted':{
                        get: function () {
                            return muted
                        },
                        set: function (v) {
                            muted = v
                        }
                    },
                    'speaking':{
                        get:function () {
                            return speaking
                        },
                        set:function (v) {
                            speaking = v
                        }
                    },
                    'muteVideo':{
                        get:function () {
                            return muteVideo
                        },
                        set:function (v) {
                            muteVideo = v
                        }
                    },
                    'deptName':{
                        get:function () {
                            return deptName
                        },
                        set:function (v) {
                            deptName = v
                        }
                    },
                    'deptId':{
                        get:function () {
                            return deptId
                        },
                        set:function (v) {
                            deptId = v
                        }
                    },
                    'roomName':{
                        get:function () {
                            return roomName
                        },
                        set:function (v) {
                            roomName = v
                        }
                    },
                    'isVcs':{
                        get:function () {
                            return isVcs
                        },
                        set:function (v) {
                            isVcs = v
                        }
                    },
                    'isTemp':{
                        get:function () {
                            return isTemp
                        },
                        set:function (v) {
                            isTemp = v
                        }
                    },
                    'isGrade':{
                        get:function () {
                            return isGrade
                        },
                        set:function (v) {
                            isGrade = v
                        }
                    },
                    'number':{
                        get:function () {
                            return number
                        },
                        set:function (v) {
                            number = v
                        }
                    },
                    'type':{
                        get:function () {
                            return type
                        },
                        set:function (v) {
                            type = v
                        }
                    },
                    'status':{
                        get:function () {
                            return status
                        },
                        set:function (v) {
                            status = v
                        }
                    },
                    'gradeNumber':{
                        get:function () {
                            return gradeNumber
                        },
                        set:function (v) {
                            gradeNumber = v
                        }
                    },
                    'gradeName':{
                        get:function () {
                            return gradeName
                        },
                        set:function (v) {
                            gradeName = v
                        }
                    },
                    'net':{
                        get:function () {
                            return net
                        },
                        set:function (v) {
                            net = v
                        }
                    },
                    'icon':{
                        get:function () {
                            return icon
                        },
                        set:function (v) {
                            icon = v
                        }
                    },
                    'meetingIcon':{
                        get:function () {
                            return meetingIcon
                        },
                        set:function (v) {
                            meetingIcon = v
                        }
                    },
                    'order':{
                        get:function () {
                            return order
                        },
                        set:function (v) {
                            order = v
                        }
                    },
                    'isRtsp':{
                        get:function () {
                            return isRtsp
                        },
                        set:function (v) {
                            isRtsp = v
                        }
                    },
                    'realName':{
                        get:function () {
                            return realName
                        },
                        set:function (v) {
                            realName = v
                        }
                    },
                    'isControl':{
                        get:function () {
                            return isControl
                        },
                        set:function (v) {
                            isControl = v
                        }
                    },
                })
            }
            Participant.prototype.getElement = function() {
                return this.muteVideo ? document.getElementById(this.audioId) : document.getElementById(this.videoId)
            }
            Participant.prototype.getAudioElement = function() {
                return document.getElementById(this.audioId)
            }
            Participant.prototype.offerToReceiveVideo = function(error, sdp, wp) {
                if (error) return logger.error('sdp offer error',error)
                window.cws.receive(this.type == '1' ? this.number : this.name, sdp)
            }
            Participant.prototype.onIceCandidate = function(candidate, wp) {
                window.cws.iceCandidate(candidate, this.type == '1' ? this.number : this.name)
            }
            Participant.prototype.setStatus = function (status) {
                this.status = status
                let st = this.status.toLowerCase()
                if (st !== 'talking') {
                    this.meetingIcon = ''
                }
                switch (st) {
                    case 'talking':
                        this.order = 0
                        break
                    case 'broading':
                        this.order = 1
                        break
                    case 'idle':
                        this.order = 2
                        break
                    case 'offline':
                        this.order = 3
                        break
                    case 'unknow':
                        this.order = 4
                        if (this.type == '4') {
                            this.isRtsp = true
                        }
                        break
                }
            }
            Participant.prototype.setMute = function(mute) {
                this.muted = mute
                if (this.muted) {
                    if (this.meetingIcon) {
                        this.meetingIcon = 'conf_mute'
                    }
                } else {
                    if (this.meetingIcon) {
                        this.meetingIcon = 'conf'
                    }
                }
            }
            Participant.prototype.mutedAudio = function (enabled,username) {
                if (this.rtcPeer && this.name == username) {
                    this.rtcPeer.peerConnection.getSenders().forEach(sender=>{
                        if (sender.track.kind == 'audio') {
                            sender.track.enabled = enabled
                            this.muted = !enabled
                        }
                    })
                }
            }
            Participant.prototype.setDept = function(deptId, deptName) {
                this.deptId = deptId
                this.deptName = deptName
            }
            Participant.prototype.dispose = function() {
                if (this.rtcPeer) {
                    this.rtcPeer.dispose()
                    this.rtcPeer = null
                }
                if (this.speakHark) {
                    this.speakHark.stop()
                    this.speakHark = null
                }
            }

            module.exports = Participant
        },{}],
        9:[function (require, module, exports) {
            if (typeof Object.create === 'function') {
                // implementation from standard node.js 'util' module
                module.exports = function inherits(ctor, superCtor) {
                    if (superCtor) {
                        ctor.super_ = superCtor
                        ctor.prototype = Object.create(superCtor.prototype, {
                            constructor: {
                                value: ctor,
                                enumerable: false,
                                writable: true,
                                configurable: true
                            }
                        })
                    }
                }
            } else {
                // old school shim for old browsers
                module.exports = function inherits(ctor, superCtor) {
                    if (superCtor) {
                        ctor.super_ = superCtor
                        var TempCtor = function () {
                        }
                        TempCtor.prototype = superCtor.prototype
                        ctor.prototype = new TempCtor()
                        ctor.prototype.constructor = ctor
                    }
                }
            }

        }, {}]
    },{},[2])(2)
})